package Servicios;

import DTO.ConstantesDTO;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * Clase que encapsula el servicio de persistencia de la aplicacion.
 * Implementa Singleton Pattern
 * @author eagle_eye
 *
 */
public class PersistenceServicio {

    private EntityManagerFactory emf;
    private static PersistenceServicio instance = new PersistenceServicio();

    private PersistenceServicio() {
    }

    public static PersistenceServicio getInstance() {
        return instance;
    }

    public EntityManagerFactory createEmf() {
        emf = Persistence.createEntityManagerFactory(ConstantesDTO.PESISTENCE_UNIT_NAME, System.getProperties());
        return emf;
    }

    public EntityManagerFactory getEmf() {
        return emf;
    }
}
